﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Chinaer.Core.Helper
{
    public sealed class FileHelper
    {
        /// <summary>
        /// 判断文件是否存在
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool CheckFileExists(string filePath)
        {
            return File.Exists(filePath);
        }
        /// <summary>
        /// 根据文件路径创建文件
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool CreateFile(string filePath)
        {
            try
            {
                File.CreateText(filePath);
                return CheckFileExists(filePath);
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 根据文件路径删除文件
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool DeleteFile(string filePath)
        {
            try
            {
                File.Delete(filePath);
                return !CheckFileExists(filePath);
            }
            catch (Exception ex)
            {
                return false;
            }
        }        

    }
}
